package test;

import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationObserver;

import java.io.File;

public class FileListener extends FileAlterationListenerAdaptor {
    public void onDirectoryCreate(File directory) {

        System.out.println("[新建]:" + directory.getAbsolutePath());

        //判断文件夹是否存在
        if(!directory.exists()){
            System.out.println("文件夹不存在");
        }
        File[] files = directory.listFiles();
        ReadResult.rename(directory.getAbsolutePath());
        String filepath = directory.getAbsolutePath()+"\\part-00000.txt";
        boolean flag = ReadResult.isEmptyFile(filepath);
        if(flag == true){
            System.out.println("-------空---------");
        }else{
            System.out.println("-------不为空---------");
            SaveLasted.pathList.add(filepath);
        }
    }
    public void onStart(FileAlterationObserver observer) {
        super.onStart(observer);
    }
    public void onStop(FileAlterationObserver observer) {
        super.onStop(observer);
    }
}
